# Python代码示例：手动实现一个神经元
import numpy as np

def simple_neuron(inputs, weights, bias, activation_function):
    """
    简单神经元实现
    inputs: 输入信号列表 [x1, x2, ..., xn]
    weights: 权重列表 [w1, w2, ..., wn]  
    bias: 偏置项
    activation_function: 激活函数
    """
    # 步骤1：加权求和
    weighted_sum = np.dot(weights, inputs) + bias
    
    # 步骤2：应用激活函数
    output = activation_function(weighted_sum)
    
    return output

# 示例使用
def sigmoid(x):
    return 1 / (1 + np.exp(-x))

inputs = [0.5, 0.3, 0.8]
weights = [0.4, 0.7, 0.2]
bias = 0.1

output = simple_neuron(inputs, weights, bias, sigmoid)
print(f"神经元输出: {output:.4f}")